package acwing._1_1AlgorithmBasic._6Greedy;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._1_1AlgorithmBasic._6Greedy
 * @File : Q0907.java
 * @Author : WangRuoyu
 * @Date : 2023/4/7 9:55
 */

import java.io.*;
import java.util.Arrays;

public class Q0907 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] words = br.readLine().split(" ");
        int ll = Integer.parseInt(words[0]);
        int rr = Integer.parseInt(words[1]);
        words = br.readLine().split(" ");
        int n = Integer.parseInt(words[0]);
        int[][] s = new int[n][2];
        for (int i = 0; i < n; ++i) {
            words = br.readLine().split(" ");
            int l = Integer.parseInt(words[0]);
            int r = Integer.parseInt(words[1]);
            s[i][0] = l;
            s[i][1] = r;
        }
        Arrays.sort(s, (o1, o2) -> o1[0] != o2[0] ? o1[0] - o2[0] : o1[1] - o2[1]);

        int cnt = 0;
        int idx = 0;
        boolean flag = false;
        while (idx < s.length) {
            if (s[idx][0] > ll) {
                break;
            }
            int maxr = Integer.MIN_VALUE;
            while (idx < s.length && s[idx][0] <= ll) {
                maxr = Math.max(maxr, s[idx][1]);
                idx++;
            }
            cnt++;
            ll = maxr;
            if (ll >= rr) {
                flag = true;
                break;
            }
        }
        if (flag) {
            System.out.println(cnt);
        } else {
            System.out.println(-1);
        }
    }
}


